#ifndef JSONHELPER_H
#define JSONHELPER_H


#include <QObject>
#include <QFile>
#include <QVariantList>

class FmData : public QObject {

    Q_OBJECT
    Q_PROPERTY(int freq READ getFreq WRITE setFreq NOTIFY freqChanged)
    Q_PROPERTY(int fav READ getFav WRITE setFav NOTIFY favChanged)
public:
    explicit FmData(QObject *parent = nullptr )
        :QObject(parent){

    }
    ~FmData(){
    }

    int getFreq() const { return this->m_freq; }
    void setFreq(int value) { this->m_freq = value; }

    int getFav() const { return this->m_fav; }
    void setFav(int value) { this->m_fav = value; }

signals:
    void freqChanged(int freq);
    void favChanged(int fav);

private:
    int m_freq ;
    int m_fav ;
};
Q_DECLARE_METATYPE(FmData*)



class JsonHelper : public QObject
{
    Q_OBJECT
public:
    explicit JsonHelper(QObject *parent = nullptr);
    ~JsonHelper();

    Q_INVOKABLE int getCurrentIndex();
    Q_INVOKABLE QVariantList getFmData();

    Q_INVOKABLE void serializeData( QVariant data );
    Q_INVOKABLE void deserializeData( QVariant key );

signals:
private:
    QString m_filePath;
    QFile m_objFile;
    QVariantList m_objFmData;
    int32_t m_i32CurrentIndex;
};

#endif // JSONHELPER_H
